package format;

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class FormatDemo {

	public static void main(String[] args) {
		double num1 = 39874.0973214;
		double num2 = 1293248.71432;
		Double num3 = Double.valueOf("21432134.34598213");

		NumberFormat fmt1 = new DecimalFormat("##.0");

		System.out.println(fmt1.format(num1));
		System.out.println(fmt1.format(num2));
		System.out.println(fmt1.format(num3));

		DecimalFormat fmt = new DecimalFormat("###");
		System.out.println(fmt.format(num1));
		System.out.println(fmt.format(num2));
		System.out.println(fmt.format(num3));

		System.out.println(fmt.format(Math.ceil(num1)));
		System.out.println(fmt.format(Math.ceil(num2)));
		System.out.println(fmt.format(Math.ceil(num3)));
	}
}
